#ifndef CACHE_H
#define CACHE_H

#include "CacheItem.h"

/// @file Cache.h
/// @brief manages caching of particles to file
/// @author Perseedoss Rajiv
/// @version 1.0
/// @date 09.08.11
/// Revision History :
/// Initial Version 09.08.11
/// @class Cache
/// @brief manage list of cache items per frame and writes them to disk at a regular interval

class Cache
{
public:
    /// @brief ctor
    Cache();

    /// @brief add cache items to the cache
    /// @param[in] _cacheItem the item to add to the cache list
    void addItem(const CacheItem& _cacheItem);

    /// @brief return the number of items in the cache
    inline int getCacheCount() const { return m_fluidCache.size(); }

    /// @brief writes the contents of the cache to file
    void flushCache(const std::string _path);

private:
    /// @brief the list of cache items held in the cache
    std::vector<CacheItem> m_fluidCache;

private:
    /// @brief write point positions (fluid and sphere) to file
    /// @param[in] _positionList the position list to write out
    /// @param[in] _filename the name of the file on disk
    void writePointData
            (
                std::vector<ngl::Vector>& _positionList,
                const std::string& _filename
            );

    /// @brief write the boundary box information to file
    /// @param[in] _positionList the position list to write out
    /// @param[in] _filename the name of the file on disk
    void writeBoundaryData
            (
                std::vector<ngl::Vector>& _positionList,
                const std::string& _filename
            );

};

#endif // CACHE_H
